{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Wine Dataset"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A function that loads the `Wine` dataset into NumPy arrays."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> from mlxtend.data import wine_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Overview"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The Wine dataset for classification.\n",
    "\n",
    "|\t\t\t\t  |\t\t  \t\t\t|\n",
    "|----------------------------|----------------|\n",
    "| Samples                    | 178            |\n",
    "| Features                   | 13             |\n",
    "| Classes                    | 3              |\n",
    "| Data Set Characteristics:  | Multivariate   |\n",
    "| Attribute Characteristics: | Integer, Real  |\n",
    "| Associated Tasks:          | Classification |\n",
    "| Missing Values             | None           |\n",
    "\n",
    "|\tcolumn| attribute\t|\n",
    "|-----|------------------------------|\n",
    "| 1)  | Class Label                  |\n",
    "| 2)  | Alcohol                      |\n",
    "| 3)  | Malic acid                   |\n",
    "| 4)  | Ash                          |\n",
    "| 5)  | Alcalinity of ash            |\n",
    "| 6)  | Magnesium                    |\n",
    "| 7)  | Total phenols                |\n",
    "| 8)  | Flavanoids                   |\n",
    "| 9)  | Nonflavanoid phenols         |\n",
    "| 10) | Proanthocyanins              |\n",
    "| 11) | Color intensity              |\n",
    "| 12) | Hue                          |\n",
    "| 13) | OD280/OD315 of diluted wines |\n",
    "| 14) | Proline                      |\n",
    "\n",
    "\n",
    "| class | samples   |\n",
    "|-------|----|\n",
    "| 0     | 59 |\n",
    "| 1     | 71 |\n",
    "| 2     | 48 |\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### References\n",
    "\n",
    "- Forina, M. et al, PARVUS - \n",
    "An Extendible Package for Data Exploration, Classification and Correlation. \n",
    "Institute of Pharmaceutical and Food Analysis and Technologies, Via Brigata Salerno, \n",
    "16147 Genoa, Italy. \n",
    "- Source: [https://archive.ics.uci.edu/ml/datasets/Wine](https://archive.ics.uci.edu/ml/datasets/Wine)\n",
    "- Bache, K. & Lichman, M. (2013). UCI Machine Learning Repository. Irvine, CA: University of California, School of Information and Computer Science."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 - Dataset overview"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dimensions: 178 x 13\n",
      "\n",
      "Header: ['alcohol', 'malic acid', 'ash', 'ash alcalinity', 'magnesium', 'total phenols', 'flavanoids', 'nonflavanoid phenols', 'proanthocyanins', 'color intensity', 'hue', 'OD280/OD315 of diluted wines', 'proline']\n",
      "1st row [  1.42300000e+01   1.71000000e+00   2.43000000e+00   1.56000000e+01\n",
      "   1.27000000e+02   2.80000000e+00   3.06000000e+00   2.80000000e-01\n",
      "   2.29000000e+00   5.64000000e+00   1.04000000e+00   3.92000000e+00\n",
      "   1.06500000e+03]\n"
     ]
    }
   ],
   "source": [
    "from mlxtend.data import wine_data\n",
    "X, y = wine_data()\n",
    "\n",
    "print('Dimensions: %s x %s' % (X.shape[0], X.shape[1]))\n",
    "print('\\nHeader: %s' % ['alcohol', 'malic acid', 'ash', 'ash alcalinity',\n",
    "                        'magnesium', 'total phenols', 'flavanoids',\n",
    "                        'nonflavanoid phenols', 'proanthocyanins',\n",
    "                        'color intensity', 'hue', 'OD280/OD315 of diluted wines',\n",
    "                        'proline'])\n",
    "print('1st row', X[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Classes: [0 1 2]\n",
      "Class distribution: [59 71 48]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "print('Classes: %s' % np.unique(y))\n",
    "print('Class distribution: %s' % np.bincount(y))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## API"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "## wine_data\n",
      "\n",
      "*wine_data()*\n",
      "\n",
      "Wine dataset.\n",
      "\n",
      "\n",
      "- `Source` : https://archive.ics.uci.edu/ml/datasets/Wine\n",
      "\n",
      "\n",
      "- `Number of samples` : 178\n",
      "\n",
      "\n",
      "- `Class labels` : {0, 1, 2}, distribution: [59, 71, 48]\n",
      "\n",
      "\n",
      "    Dataset Attributes:\n",
      "\n",
      "    - 1) Alcohol\n",
      "    - 2) Malic acid\n",
      "    - 3) Ash\n",
      "    - 4) Alcalinity of ash\n",
      "    - 5) Magnesium\n",
      "    - 6) Total phenols\n",
      "    - 7) Flavanoids\n",
      "    - 8) Nonflavanoid phenols\n",
      "    - 9) Proanthocyanins\n",
      "    - 10) Color intensity\n",
      "    - 11) Hue\n",
      "    - 12) OD280/OD315 of diluted wines\n",
      "    - 13) Proline\n",
      "\n",
      "**Returns**\n",
      "\n",
      "- `X, y` : [n_samples, n_features], [n_class_labels]\n",
      "\n",
      "    X is the feature matrix with 178 wine samples as rows\n",
      "    and 13 feature columns.\n",
      "    y is a 1-dimensional array of the 3 class labels 0, 1, 2\n",
      "\n",
      "**Examples**\n",
      "\n",
      "For usage examples, please see\n",
      "    [http://rasbt.github.io/mlxtend/user_guide/data/wine_data](http://rasbt.github.io/mlxtend/user_guide/data/wine_data)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "with open('../../api_modules/mlxtend.data/wine_data.md', 'r') as f:\n",
    "    print(f.read())"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  },
  "toc": {
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
